<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CC的办公系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
	.ui-datepicker table {
		border: 0;
	}
</style>
<script type="text/javascript">
	$(function() {
		$("form").validationEngine();
	});
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
if not CheckPostFlag(session("aaPostFlag"),3,15) then call JumpErrorPage(2)
submit=request.form("submit")
If submit<>"" Then
	conn.BeginTrans
	brand_id=request.form("brand_id")
	brand_name=request.form("brand_name")
	if submit="新增" then
		sql="insert into brand(brand_name) values('"&brand_name&"')"
		brand_id=ExecuteCommand(sql,true)
	end if
	if submit="保存" then
		sql="update brand set brand_name='"&brand_name&"' where brand_id="&brand_id
		call ExecuteCommand(sql,false)
	end if
	if err.number=0 then 
		conn.CommitTrans  '如果没有conn错误，则执行事务提交
	else
		conn.RollbackTrans '否则回滚
		'回滚后的其他操作
		'strerr=err.Description
		url=request.ServerVariables("http_host")&request.ServerVariables("url")
		Response.Write "数据库错误！<br /><font color=red>Error # " & CStr(Err.Number) & "<br />" & Err.Description & "<br />Source: " & Err.Source &"<br />错误页面："&url&"</font><br />"
		Response.End
	end if
else
	brand_id=request.querystring("brand_id")
end if

if brand_id<>"" then
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql="select * from brand where brand_id="&brand_id
	rs.Open sql,conn,1,1
	if not rs.eof then
		brand_name=rs("brand_name")
	else
		response.write("没有此品牌")
		response.end
	end if
	rs.close
	set rs=nothing
end if	
	
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">
<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
	<div id="col3" role="main">
		<div id="col3_content" class="clearfix">
			<form name="form1" id="form1" method="post" class="yform" role="application">
			品牌：	<input name="brand_name" id="brand_name" class="validate[required]" value="<%=brand_name%>" />
					<input type="hidden" name="brand_id" value="<%=brand_id%>" />
					<%if brand_id<>"" then%>
					<input type="submit" name="submit" value="保存" />
					<%end if%>
					<input type="submit" name="submit" value="新增" />
					<input name="reset" type="reset" value="重置" />
			</form>		
			<table class="full">
				<thead>
					<tr>
						<th>序号</th>
						<th>品牌</th>
						<th>删除</th>
					</tr>
				</thead>
				<tbody>
			<%
				Set rs = Server.CreateObject("ADODB.Recordset")
				sql = "select * from brand order by brand_name"
				rs.Open sql,conn,1,1
				do while not rs.eof

			%>
					<tr>
						<td><%=rs.AbsolutePosition%></td>
						<td><a href="brand.asp?brand_id=<%=rs("brand_id")%>"><%=rs("brand_name")%></a></td>
						<td><a href="del_brand.asp?brand_id=<%=rs("brand_id")%>">删除</a></td>
					</tr>
			<%
					rs.movenext
				loop
				rs.close
				set rs=nothing
			%>
				</tbody>
			</table>
		</div>
	</div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

